<div class="panel panel-danger" ng-if="!success">
    <div class="panel-heading">
        <strong>{{(artifact.data || artifact.attachment.name) | fang}}</strong>
    </div>
    <div class="panel-body">
        {{content.errorMessage}}
    </div>
</div>

<div ng-switch="content.response_code" ng-if="success">
    <div ng-switch-when="1">
        <div class="panel panel-info">
            <div class="panel-heading">
                <strong>Summary</strong>
            </div>
            <div class="panel-body">
                <dl class="dl-horizontal" ng-if="content.positives">
                    <dt>Score</dt>
                    <dd class="wrap">{{content.positives || 0}}/{{content.total}}</dd>
                </dl>
                <dl class="dl-horizontal" ng-if="content.scan_date">
                    <dt>Last analysis date</dt>
                    <dd class="wrap">{{content.scan_date}}</dd>
                </dl>
                <dl class="dl-horizontal" ng-if="content.as_owner">
                    <dt>Autonomous System</dt>
                    <dd class="wrap">{{content.as_owner}}</dd>
                </dl>
                <dl class="dl-horizontal" ng-if="content.categories">
                    <dt>Categories</dt>
                    <dd class="wrap">{{content.categories.join(', ')}}</dd>
                </dl>
                <dl class="dl-horizontal" ng-if="content.subdomains">
                    <dt>Sub domains</dt>
                    <dd class="wrap">{{content.subdomains.join(', ')}}</dd>
                </dl>
                <dl class="dl-horizontal" ng-if="content.resolutions && content.resolutions.length > 0">
                    <dt>Resolutions</dt>
                    <dd>
                        <div ng-if="::artifact.dataType === 'domain'">
                            <strong>This domain has been seen to resolve to the following IP addresses.</strong>
                        </div>
                        <div ng-if="::artifact.dataType === 'ip'">
                            <strong>The following domains resolved to the given IP address.</strong>
                        </div>
                        <div ng-repeat="resolution in ::content.resolutions | limitTo:20">
                            {{::resolution.last_resolved | amDateFormat:'DD-MM-YYYY'}}:
                            <span class="text-danger wrap">{{(resolution.ip_address | fang) || (resolution.hostname | fang)}}</span>
                        </div>
                    </dd>
                </dl>
                <dl class="dl-horizontal" ng-if="['ip', 'domain', 'hash'].indexOf(artifact.dataType) !== -1">
                    <dt>Virus Total</dt>
                    <dd>
                        <span ng-if="artifact.dataType === 'domain'">
                            <i class="fa fa-search"></i>
                            <a ng-href="https://www.virustotal.com/en/domain/{{artifact.data}}/information/" target="_blank">
                                View Full Report</a>
                        </span>
                        <span ng-if="artifact.dataType === 'ip'">
                            <i class="fa fa-search"></i>
                            <a ng-href="https://www.virustotal.com/en/ip-address/{{artifact.data}}/information/" target="_blank">
                                View Full Report</a>
                        </span>
                        <span ng-if="artifact.dataType === 'hash'">
                            <i class="fa fa-search"></i>
                            <a ng-href="https://www.virustotal.com/en/file/{{artifact.data}}/analysis/" target="_blank">
                                View Full Report</a>
                        </span>
                    </dd>
                </dl>
            </div>
        </div>

        <div class="panel panel-info" ng-if="::content.detected_urls" ng-init="detected_urls_limit = 20">
            <div class="panel-heading">
                <strong>Latest detected URLs</strong>
                <span class="pull-right" ng-if="::content.detected_urls.length > 20">
                    <a ng-click="detected_urls_limit = undefined">View All ({{::content.detected_urls.length}})</a>
                </span>
            </div>
            <div class="panel-body">
                <p>Latest URLs hosted in this IP address
                    <strong>detected by at least one URL scanner or malicious URL dataset.</strong>
                </p>
                <table class="table table-hover">
                    <tr>
                        <th>Score</th>
                        <th>Scan Date</th>
                        <th>URL</th>
                    </tr>
                    <tr ng-repeat="url in content.detected_urls | limitTo:detected_urls_limit">
                        <td>
                            <span ng-class="{'text-danger': url.positives > 0}">{{::url.positives}}/{{::url.total}}</span>
                        </td>
                        <td>{{url.scan_date}}</td>
                        <td class="wrap">{{url.url | fang}}</td>
                    </tr>
                </table>
            </div>
        </div>

        <div class="panel panel-info" ng-if="content.detected_downloaded_samples" ng-init="detected_downloaded_samples_limit=20">
            <div class="panel-heading">
                <strong>Latest detected files that were downloaded from this IP address</strong>
                <span class="pull-right" ng-if="::content.detected_downloaded_samples.length > 20">
                    <a ng-click="detected_downloaded_samples_limit = undefined">View All ({{::content.detected_downloaded_samples.length}})</a>
                </span>
            </div>
            <div class="panel-body">
                <p>Latest files that are
                    <strong>detected by at least one antivirus solution and were downloaded by VirusTotal from the IP address provided.</strong>
                </p>
                <table class="table table-hover">
                    <tr>
                        <th>Score</th>
                        <th>Date</th>
                        <th>SHA256</th>
                    </tr>
                    <tr ng-repeat="hash in content.detected_downloaded_samples | limitTo:detected_downloaded_samples_limit">
                        <td>
                            <span ng-class="{'text-danger': hash.positives > 0}">{{hash.positives}}/{{hash.total}}</span>
                        </td>
                        <td>{{hash.date}}</td>
                        <td>{{hash.sha256}}</td>
                    </tr>
                </table>
            </div>
        </div>

        <div class="panel panel-info" ng-if="content.detected_referrer_samples" ng-init="detected_referrer_samples_limit=20">
            <div class="panel-heading">
                <strong>Latest detected files that embed this IP address in their strings</strong>
                <span class="pull-right" ng-if="::content.detected_referrer_samples.length > 20">
                    <a ng-click="detected_referrer_samples_limit = undefined">View All ({{::content.detected_referrer_samples.length}})</a>
                </span>
            </div>
            <div class="panel-body">
                <p>Latest files that are
                    <strong>detected by at least one antivirus solution and embed URL pattern strings with the IP address provided.</strong>
                </p>
                <table class="table table-hover">
                    <tr>
                        <th>Score</th>
                        <th>SHA256</th>
                    </tr>
                    <tr ng-repeat="hash in content.detected_referrer_samples | limitTo:detected_referrer_samples_limit">
                        <td>
                            <span ng-class="{'text-danger': hash.positives > 0}">{{hash.positives}}/{{hash.total}}</span>
                        </td>
                        <td>{{hash.sha256}}</td>
                    </tr>
                </table>
            </div>
        </div>

        <div class="panel panel-info" ng-if="content.scans">
            <div class="panel-heading">
                <strong>Scans</strong>
            </div>
            <div class="panel-body">

                <table class="table table-hover">
                    <tr>
                        <th>Scanner</th>
                        <th>Detected</th>
                        <th>Result</th>
                        <th>Details</th>
                        <th>Update</th>
                        <th>Version</th>
                    </tr>
                    <tr ng-init="result.unrated = (result.result === 'unrated site')" ng-repeat="(scanner, result) in content.scans">
                        <td>
                            <strong>{{scanner}}</strong>
                        </td>
                        <td>
                            <i ng-class="{'text-danger fa fa-bug': result.detected, 'text-success fa fa-check-circle': !result.detected && !result.unrated, 'text-info fa fa-question-circle': result.unrated}"></i>
                        </td>
                        <td ng-class="{'text-info': result.unrated, 'text-danger': result.detected, 'text-success': !result.detected && !result.unrated}" class="wrap">{{result.result}}</td>
                        <td>
                            <a ng-href="{{result.detail}}" ng-if="result.detail" target="_blank">
                                <i class="fa fa-search"></i>
                                View details</a>
                        </td>
                        <td>{{result.update}}</td>
                        <td>{{result.version}}</td>
                    </tr>
                </table>
            </div>
        </div>

    </div>
    <div ng-switch-default>
        <div class="panel panel-danger">
            <div class="panel-heading">
                <strong>{{(artifact.data || artifact.attachment.name) | fang}}</strong>
            </div>
            <div class="panel-body">
                {{content.verbose_msg}}
            </div>
        </div>
    </div>
</div>
